<form id="dayoffSubmit-form" lay-filter="dayoffSubmit-form" class="layui-form model-form">
    <div class="layui-form-item">
        <label class="layui-form-label">临时请假日期</label>
        <div class="layui-input-block">
            <input id="time" name="time" class="layui-input" placeholder="YYYY-MM-dd" type="date">
        </div>
    </div>

    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="dayoffSubmit-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['form', 'table', 'util', 'config', 'index','admin','layedit'], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
        var index = layui.index;
        var admin = layui.admin;
        let userinfo = "";
        var layedit=layui.layedit;
        //获取值
        var daily = admin.getTempData('t_dayoff');

        //修改赋值
        if (daily){
            form.render();
            console.log(daily,333333);
        }else{
            console.log(daily,44444);
            daily={
                id:null
            }
            console.log(daily.id,55555);
        }


        // form.val('user-form', user);
        // 表单提交事件
        form.on('submit(dayoffSubmit-form-submit)', function (data) {
            layer.load(2);

            let res={
                id:daily.id,
                time:data.field.time,
            };

            admin.req('api-sign/dayoff/dayoffSubmitOrUpdate', JSON.stringify(res), function (data) {
                layer.closeAll('loading');
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1, time: 500});
                    admin.finishPopupCenter();
                } else {
                    layer.msg(data.msg, {icon: 2, time: 500});
                }
            }, "POST");

            return false;
        });
    });
</script>